import Opt from '@/components/dt/info/Opt.js'

class Column extends Opt {

  constructor() {
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [{
        field: 'orgName',
        title: '所属组织',
        minWidth: 160
      },
      {
        field: 'housesName',
        title: '案场名称',
        minWidth: 180
      },
      {
        field: 'status',
        minWidth: 120,
        cell: {
          text: {
            type: 'dict',
            key: 'buildStatus'
          }
        },
        header: {
          filter: {
            title: '案场状态',
            key: 'status',
            select: {
              key: 'buildStatus'
            }
          }
        }
      },
      {
        field: 'contractBeginTime',
        minWidth: 140,
        header: {
          filter: {
            title: '合同开始日期',
            key: 'contractBeginTime',
            placeholder: '请选择',
            date: {
              type: 'daterange'
            },
            data: {
              from: (val) => {
                if (val.contractBeginStartTime && val.contractBeginEndTime) {
                  let start = val.contractBeginStartTime.slice(0, 10)
                  let end = val.contractBeginEndTime.slice(0, 10)
                  return [start, end]
                }
                return
              },
              to: (val) => {
                return {
                  contractBeginStartTime: val[0],
                  contractBeginEndTime: val[1]
                }
              }
            }
          }
        },
      },
      {
        field: 'contractEndTime',
        minWidth: 140,
        header: {
          filter: {
            title: '合同结束日期',
            key: 'contractEndTime',
            placeholder: '请选择',
            date: {
              type: 'daterange'
            },
            data: {
              from: (val) => {
                if (val.contractEndStartTime && val.contractEndEndTime) {
                  let start = val.contractEndStartTime.slice(0, 10)
                  let end = val.contractEndEndTime.slice(0, 10)
                  return [start, end]
                }
                return
              },
              to: (val) => {
                return {
                  contractEndStartTime: val[0],
                  contractEndEndTime: val[1]
                }
              }
            }
          }
        }
      },
      {
        field: 'contractInformNum',
        title: '合同数量',
        minWidth: 100,
      },
      {
        field: 'isAttach',
        title: '是否上传附件',
        minWidth: 140,
        cell: {
          value: (item) => item.isAttach == '1' ? '是' : item.isAttach == '0' ? '否' : '',
          text: {}
        }
      },
      {
        field: 'isReNew',
        minWidth: 100,
        cell: {
          value: (item) => item.isReNew == '1' ? '是' : item.isReNew == '0' ? '否' : '',
          text: {}
        },
        header: {
          filter: {
            title: '是否续签',
            key: 'isReNew',
            select: {
              options: [
                { key: '1', value: '是' },
                { key: '0', value: '否' }
              ]
            }
          }
        }
      },
      {
        field: 'isWithdrawal',
        minWidth: 110,
        cell: {
          value: (item) => item.isWithdrawal == '1' ? '是' : item.isWithdrawal == '0' ? '否' : '',
          text: {}
        },
        header: {
          filter: {
            title: '是否撤场',
            key: 'isWithdrawal',
            select: {
              options: [
                { key: '1', value: '是' },
                { key: '0', value: '否' }
              ]
            }
          }
        }
      },
      {
        field: 'realityWithdrawalDate',
        minWidth: 120,
        cell: {
          text: {
            type: 'date'
          }
        },
        header: {
          filter: {
            title: '撤场日期', 
            key: 'realityWithdrawalDate',
            placeholder: '请选择',
            date: {
              type: 'daterange'
            },
            data: {
              from: (val) => {
                if (val.realityWithdrawalStartDate && val.realityWithdrawalEndDate) {
                  let start = val.realityWithdrawalStartDate.slice(0, 10)
                  let end = val.realityWithdrawalEndDate.slice(0, 10)
                  return [start, end]
                }
                return
              },
              to: (val) => {
                return {
                  realityWithdrawalStartDate: val[0],
                  realityWithdrawalEndDate: val[1]
                }
              }
            }
          }
        }
      },
      {
        field: 'isWithdrawalDeal',
        minWidth: 160,
        cell: {
          value: (item) => item.isWithdrawalDeal == '1' ? '是' : item.isWithdrawalDeal == '0' ? '否' : '',
          text: {}
        },
        header: {
          filter: {
            title: '撤场协议是否签署',
            key: 'isWithdrawalDeal',
            select: {
              options: [
                { key: '1', value: '是' },
                { key: '0', value: '否' }
              ]
            }
          }
        }
      },
      {
        field: 'unSettlementRoomInfo',
        minWidth: 260,
        cell: {
          value: (item) => item.unSettlementRoomInfo == '1' ? '是' : item.unSettlementRoomInfo == '0' ? '否' : '',
          text: {}
        },
        header: {
          filter: {
            title: '是否包含剩余未结算房源成交明细',
            key: 'unSettlementRoomInfo',
            select: {
              options: [
                { key: '1', value: '是' },
                { key: '0', value: '否' }
              ]
            }
          }
        }
      },
      {
        title: '操作',
        fixed: 'right',
        width: 140,
        align: 'center',
        cell: (item) => {
          return {
            btn: [{
              title: '查看明细',
              event: 'linkDetailFun',
              data: item.housesId
            }]
          }
        }
      }
    ]
  }

}

export default Column